package com.turing.usdtpay.mvp.view;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.turing.usdtpay.R;


public class BaseTitleView extends RelativeLayout {

    private ImageView mRightIv,mLogo,mLeftIv;
    private TextView mTitle,mRightTv;

    public BaseTitleView(Context context) {
        super(context);

    }

    public BaseTitleView(Context context, AttributeSet attrs) {
        super(context, attrs);
        LayoutInflater.from(context).inflate(R.layout.layout_base_title,this,true);
        mLeftIv = (ImageView) findViewById(R.id.base_left_iv);
        mRightIv = (ImageView) findViewById(R.id.base_right_iv);
        mTitle = (TextView) findViewById(R.id.base_title);
        mLogo = (ImageView) findViewById(R.id.base_logo);
        mRightTv = (TextView) findViewById(R.id.base_right_tv);
    }

    public void setLogo(int resId){
        mLogo.setBackgroundResource(resId);
    }

    public void setOnClickLogo(OnClickListener listener){
        mLogo.setOnClickListener(listener);
    }

    public void setLeftButtonListener(OnClickListener listener){
        mLeftIv.setOnClickListener(listener);
    }

    public void setRightButtonListener(OnClickListener listener){
        mRightTv.setOnClickListener(listener);
    }

    public void setTitle(String title){
        mTitle.setText(title);
    }

    public void setRightShow(String text,boolean enable){
        mRightTv.setText(text);
        if (enable){
            mRightTv.setVisibility(VISIBLE);
        }else {
            mRightTv.setVisibility(GONE);
        }
    }

    public void setLeftShow(boolean enable){
        if (enable){
            mLeftIv.setVisibility(VISIBLE);
        }else {
            mLeftIv.setVisibility(GONE);
        }
    }

    public void setLogoShow(boolean show){
        if (show){
            mLogo.setVisibility(VISIBLE);
        }else {
            mLogo.setVisibility(GONE);
        }
    }
}
